package com.buaa.hyf.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

import com.buaa.hyf.activity.MainActivity;
import com.buaa.hyf.util.Globals;

/**
 * Created by Jeson on 2016/4/21.
 */
public class MyView extends View {


    private  String content ;
    private MainActivity a;
    public MyView(Context context) {
        super(context);
    }

    public MyView(Context context, AttributeSet attrs) {
        super(context, attrs);
        a = (MainActivity)context;
    }

    public MyView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        Paint paint = new Paint();
        paint.setColor(Color.BLACK);
        paint.setTextSize(Globals.CHAR_SIZE);

        if(content!=null){

            for(int i = 0;i < Globals.LINE_COUNT;i++){   //行
                for (int j = 0 ; j < Globals.LINT_CHAR_COUNT ; j ++){   //列
                    if(i*Globals.LINT_CHAR_COUNT+j<content.length()){
                        canvas.drawText(String.valueOf(content.charAt(j+i*Globals.LINT_CHAR_COUNT)),
                                j*(Globals.CHAR_SIZE+Globals.CHAR_SEP)+Globals.PAGE_SEP,
                                (i+1)*(Globals.CHAR_SIZE+Globals.LINT_SEP),
                                paint);
                    }
                }
            }
        }

    }



}
